#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////
void calc_bollinger(tagUMyCalcFormula*pFormula,long numCalc,phistory_data paData,double*dataCalc[10],long decNum,long sec_type,_procReflection procReflection)
{
	long i=0;
	double seedPrice(__price_seed__[decNum]);
	double*pcdClose=dataCalc[9];
	double*BOLL=dataCalc[1];

	for(i=0;i<numCalc;++i)
		pcdClose[i] = paData[i].ClosePx/seedPrice;

	memcpy(BOLL,pcdClose,numCalc*sizeof(double));
	UMyCalc_MA(BOLL,numCalc,pFormula->infoParam[0].nowValue);
	UMyCalc_STD(dataCalc[3],BOLL,numCalc,pFormula->infoParam[0].nowValue);
	
	for(i=0;i<numCalc&&(UMyCalc_invalid(dataCalc[3][i])||UMyCalc_invalid(BOLL[i]));++i);
	for(;i<numCalc;++i)
	{
		dataCalc[0][i] = BOLL[i] + 2*dataCalc[3][i];
		dataCalc[2][i] = BOLL[i] - 2*dataCalc[3][i];
	}
}
